/**
 * ChartAction.java
 *2014年5月10日下午8:23:56
 *LINKT
 */
package com.bh.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @author LINKT
 *
 */
@SuppressWarnings("serial")
public class ChartAction extends BaseAction {

        public void getCountDay(){
                
                GregorianCalendar gc=new GregorianCalendar();
                gc.setTime(new Date());
                gc.add(5, -9);                
                JSONObject jo=new JSONObject();
                jo.put("subtitle", new SimpleDateFormat("yyyy年MM月dd日").format(gc.getTime()) +"-" +  new SimpleDateFormat("yyyy年MM月dd日").format(new Date()));
                JSONArray xja=new JSONArray();
                for (int i = 0; i <10; i++) {
                        xja.add(new SimpleDateFormat("MM-dd").format(gc.getTime()));
                        gc.add(5, 1);
                }
                jo.put("xdata",xja );
                
                JSONArray yja=new JSONArray();
                for (int i = 0; i < 10; i++) {
                        yja.add(i*(int)(Math.random()*100));
                }
                jo.put("ydata", yja);
                
                this.out(jo.toString());
        }
        public void getCountMonth(){
                GregorianCalendar gc=new GregorianCalendar();
                gc.setTime(new Date());
                gc.add(2, -11);                
                JSONObject jo=new JSONObject();
                jo.put("subtitle", new SimpleDateFormat("yyyy年MM月").format(gc.getTime()) +"-" +  new SimpleDateFormat("yyyy年MM月").format(new Date()));
                JSONArray xja=new JSONArray();
                for (int i = 0; i <12; i++) {
                        xja.add(new SimpleDateFormat("yyyy-MM").format(gc.getTime()));
                        gc.add(2, 1);
                }
                jo.put("xdata",xja );
                
                JSONArray yja=new JSONArray();
                for (int i = 0; i < 12; i++) {
                        yja.add(i*(int)(Math.random()*100));
                }
                jo.put("ydata", yja);
                
                this.out(jo.toString());
        }        
        public void getCountYear(){
                GregorianCalendar gc=new GregorianCalendar();
                gc.setTime(new Date());
                gc.add(1, -4);                
                JSONObject jo=new JSONObject();
                jo.put("subtitle", new SimpleDateFormat("yyyy年").format(gc.getTime()) +"-" +  new SimpleDateFormat("yyyy年").format(new Date()));
                JSONArray xja=new JSONArray();
                gc.setTime(new Date());
                for (int i = 0; i <5; i++) {
                        xja.add(new SimpleDateFormat("yyyy年").format(gc.getTime()));
                        gc.add(1, -1);
                }
                jo.put("xdata",xja );
                
                JSONArray yja=new JSONArray();
                for (int i = 0; i < 5; i++) {
                        yja.add(i*(int)(Math.random()*100));
                }
                jo.put("ydata", yja);
                
                this.out(jo.toString());
        }        
}
